<template>
  <div class="login-wrap">
    <img class="bgImg" src="@/assets/img/login/back_bg.png" alt="" />
    <div class="loginCONBOX">
      <div class="login_content">
        <div class="text">
          <div>欢迎登录</div>
          <div>Welcome!</div>
        </div>
        <div class="input_box">
          <div class="input_box_text">账号</div>
          <input type="text" v-model="userCode" />
        </div>
        <div class="input_box" style="margin-top: 10px">
          <div class="input_box_text">密码</div>
          <input type="password" v-model="userPsd" />
        </div>
        <button class="submit" style="margin-top: 70px" @click="submit">
          <span v-if="flag">登 录</span>
          <span v-else>登 录 中...</span>
        </button>
      </div>
    </div>
  </div>
</template>
<script >
import { login } from "@/api/login";
export default {
  name: "login",
  data() {
    return {
      userCode: "18600000001",
      userPsd: "123456",
      flag: true,
    };
  },
  // 创建完毕状态(里面是操作)
  created() { },
  // 里面的函数只有调用才会执行
  methods: {
    submit() {
      this.flag = false;
      login({
        account: this.userCode,
        password: this.userPsd,
      }).then((res) => {
        this.flag = false;
        console.log(res);
        if (res.code == "200") {
          localStorage.removeItem("Authorization");
          localStorage.setItem("Authorization", res.data.token);
          localStorage.setItem("userInfo", JSON.stringify(res.data));
          this.$message({
            type: "success",
            message: "登陆成功",
          });
          setTimeout(() => {
            this.$router.push({ path: "/userInfo/userInfo" });
          }, 1500);
        } else {
          this.$message.info(res.msg);
        }
      });
      console.log(123);
    },
  },
};
</script>

<style scoped>
button {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
}

.submit {
  width: 412px;
  height: 48px;
  position: relative;
  text-align: center;
  line-height: 48px;
  background-color: #fa884f;
  border-radius: 20px;
  color: #ffffff;
}

.submit img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.submit span {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  color: #fff;
}

.login-wrap {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.bgImg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

.login_content {
  width: 412px;
  height: 477px;
  /* background-color: red; */
  margin: 0 auto;
  margin-top: 20%;
}

.text {
  font-size: 32px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #11142d;
}

.input_box {
  width: 412px;
  height: 80px;
  background: #ffffff;
  border-radius: 12px;
  border: 2px solid #555555;
  padding-top: 20px;
  padding-left: 24px;
  box-sizing: border-box;
}

.input_box_text {
  font-size: 10px;
  font-weight: 400;
  color: #808191;
}

.input_box input {
  border: none;
  outline: none;
  margin-top: 10px;
}

input:focus {
  border: none;
}

.loginCONBOX {
  position: absolute;
  top: 0;
  right: 0;
  width: 600px;
  height: 100vh;
  background: #ffffff;
  box-shadow: 0px 2px 89px 24px rgba(255, 112, 16, 0.15);
  border-radius: 100px 0px 0px 100px;
}

.loginCONBOXimg {
  width: 700px;
  height: 100vh;
  background-color: #fff;
  border-radius: 50px;
  position: absolute;
  top: 0;
  right: 0;
}
</style>